<?php
class ViewProductsController extends AppController {

	var $name = 'ViewProducts';
	var $uses = array('Product','Category');
	function index($id=null) {
		
		$lang=$this->Session->read('lag');
		if(! $id){
			$name=$_SERVER['HTTP_REFERER'];
			$this->redirect($name);
		}else{
			$this->data=$this->Product->read(null,$id);
			$name=$this->Category->findById($this->data['Product']['category_id']);			
			$this->set('name_Ct',$name['Category']['name']);			
			$this->set('list',$this->Product->find('all',array('conditions'=>array('Product.id <>'=>$id,'Product.status'=>1,'Product.category_id'=>$name['Category']['id'],'Product.lang_id'=>$lang))));
			
			
		}

	}
}
?>